******************************************************************************************************
******************************************************************************************************
//-----------------------------DEMOCRACY AND MASS SKEPTICISM OF SCIENCE-----------------------------//
//-------------------------------------  WORLD POLITICS  -------------------------------------------//
//------------------------------ For Replication and Publication -----------------------------------//
//------------------------------------ (WVS Table A.13 - A.14) ---------------------------------------//
******************************************************************************************************
******************************************************************************************************
//---------------NOTES---------------//
** Author: Junyan Jiang, Kin-Man Wan
** Last Updated: 
** Environment: 
*** Stata 17 SE
*** Windows 11 x64, AMD Ryzen 7 4800HS
*** 16GB RAM

//---------------TABLE A.13: Analysis of Science Attitudes from the WVS ---------------//
use DATA_WP_jiang_wan_wvs, clear
global cov  i.female i.emp  i.income2 age   E033

eststo clear
local var dexp_demo6_14after
reghdfe science_worldbetter  $cov   c.(`var')##i.edulevel2    if wave>=6 , a(X048ISO   wave i.birthyear##i.edulevel2) cluster(country_cohort)
local r2=e(r2_a)
eststo m1: expint science_worldbetter `var'     
estadd scalar r2a=`r2'
estadd local ctrl2 "$\checkmark$"
estadd local ctrl1 "$\checkmark$"
estadd local rfe "$\checkmark$"

local var dexp_demo6_14after
reghdfe science_lifebetter $cov   c.`var'##i.edulevel2    if wave>=6  , a(X048ISO   wave i.birthyear##i.edulevel2) cluster(country_cohort)
local r2=e(r2_a)
eststo m2: expint science_lifebetter `var' 
estadd scalar r2a=`r2'
estadd local ctrl2 "$\checkmark$"
estadd local ctrl1 "$\checkmark$"
estadd local rfe "$\checkmark$"

local var dexp_demo6_14after
reghdfe science_toomuch  $cov   c.`var'##i.edulevel2  if wave>=6 , a(X048ISO   wave i.birthyear##i.edulevel2) cluster(country_cohort)
local r2=e(r2_a)
eststo m3: expint science_toomuch `var'  
estadd scalar r2a=`r2'
estadd local ctrl2 "$\checkmark$"
estadd local ctrl1 "$\checkmark$"
estadd local rfe "$\checkmark$"

local var dexp_demo6_14after
reghdfe science_noright  $cov   c.`var'##i.edulevel2  if wave>=6 , a(X048ISO wave i.birthyear##i.edulevel2) cluster(country_cohort)
local r2=e(r2_a)
eststo m4: expint science_noright `var'  
estadd scalar r2a=`r2'
estadd local ctrl2 "$\checkmark$"
estadd local ctrl1 "$\checkmark$"
estadd local rfe "$\checkmark$"

local var dexp_demo6_14after
reghdfe religion_over_science  $cov  c.`var'##i.edulevel2  if wave>=6 , a(X048ISO   wave i.birthyear##i.edulevel2) cluster(country_cohort) 
local r2=e(r2_a)
eststo m5: expint religion_over_science `var'  
estadd scalar r2a=`r2'
estadd local ctrl2 "$\checkmark$"
estadd local ctrl1 "$\checkmark$"
estadd local rfe "$\checkmark$"

esttab  m* using out.txt, b(3) se(3) nonote nobaselevel  unstack noomitted  eqlabel(none) label  replace booktabs  star(+ 0.1 * 0.05 ** 0.01)refcat(primary "{\emph{Effect of democracy on ...}}" , nolabel) /// 
varlabel(primary "Primary education or below" secondary "Secondary education" tertiary "College education or above") ///
nomtitles ///
mgroup("The world is better off because of science and technology" "Science and technology are making our lives healthier, easier, and more comfortable"  "We depend too much on science and not enough on faith" "One of the bad effects of science is that it breaks down people's ideas of right and wrong" "Whenever science and religion conflict, religion is always right", pattern(1 1 1 1 1 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(rfe ctrl1 ctrl2 r2a  N, labels("Country FE" "Birth year and survey wave FE"  "Covariates" "Adjusted R$^2$"  "Observations") fmt(  0  0  0 2 0 ) )



//---------------TABLE A.14: Democracy and Post-Materialist Values ---------------//
label var dexp_polity_14after "Polity score (continuous, age 14 to present)"
label var dexp_demo6_14after "Polity score (binary, age 14 to present)"
label var dexp_elecd_14after "Electoral democracy (V-Dem, age 14 to present)"

eststo clear
eststo m1: reghdfe Y001  dexp_demo6_14after   $cov   i.edulevel2 , a(S003   wave i.birthyear##i.edulevel2) cluster(country_cohort)
estadd local sfe "$\checkmark$"
estadd local bfe "$\checkmark$"
estadd local cfe "$\checkmark$"
estadd local cov "$\checkmark$"

eststo m2: reghdfe Y001  dexp_polity_14after   $cov   i.edulevel2    , a(S003   wave i.birthyear##i.edulevel2) cluster(country_cohort)
estadd local sfe "$\checkmark$"
estadd local bfe "$\checkmark$"
estadd local cfe "$\checkmark$"
estadd local cov "$\checkmark$"

eststo m3: reghdfe Y001  dexp_elecd_14after   $cov   i.edulevel2    , a(S003   wave i.birthyear##i.edulevel2) cluster(country_cohort)
estadd local sfe "$\checkmark$"
estadd local bfe "$\checkmark$"
estadd local cfe "$\checkmark$"
estadd local cov "$\checkmark$"

esttab  m* using out.txt, b(3) se(3) nonote nobaselevel  unstack noomitted  eqlabel(none) label nomtitles  replace booktabs  star(+ 0.1 * 0.05 ** 0.01)keep(dexp_demo6_14after dexp_polity_14after dexp_elecd_14after) mgroup("DV: post-materialist value index" , pattern(1 0  ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(  cfe bfe sfe  cov  N, labels("Country FE" "Birth year-education FE" "Survey wave FE"  "Covariates"   "Observations") fmt(  0  0  0   0 0 ) )




************************************************************************************************
************************************************************************************************
***************************** NUMERICAL DATA/RESULTS FOR FIGURES  ******************************
************************************************************************************************
************************************************************************************************
//---------------FIGURE A.2: Validation of Science Attitudes: WGM vs. WVS---------------//
**WVS PART
preserve
g religous_alwaysright=religion_over_science if wave==6
collapse (mean)  religous_alwaysright ,by(country_name edulevel2)
save "[F]DATA_wvs_religion_byedu.dta", replace
restore








